#include <stdio.h>
#include "fan.h"
#include "file_io.h"

// 定义控制风扇的函数
int control_fan(float temperature) {
    if (temperature > 29.0f) {
        // 温度超过29度，打开风扇
        write_file("/sys/class/hwmon/hwmon1/pwm1", "100");
        printf("风扇已打开\n");
    } else {
        // 温度不超过29度，关闭风扇
        write_file("/sys/class/hwmon/hwmon1/pwm1", "0");
        printf("风扇已关闭\n");
    }
    return 0;
}
